package com.lanou.myapplication.entertainmentAdapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lanou.myapplication.Toplinefragment.HeadLineFragment1;
import com.lanou.myapplication.entertainmentFragment.HeadLineFragment2;
import com.lanou.myapplication.entity.Entertainment;
import com.lanou.myapplication.entity.Topline;

import java.util.List;

/**
 * Created by dllo on 15/10/23.
 */
public class ViewPagerAdapter2 extends FragmentPagerAdapter {
    private List<Entertainment.T1348648517839Entity> t1348648517839Entities;

    public void addData(List<Entertainment.T1348648517839Entity> data){
        t1348648517839Entities =data;
      notifyDataSetChanged();
    }


    public ViewPagerAdapter2(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        Entertainment.T1348648517839Entity l =  t1348648517839Entities.get(position);
        String title =l.getTitle();
        String imgsrc=l.getImgsrc();

        return HeadLineFragment2.getInstance(title, imgsrc);
    }

    @Override
    public int getCount() {
        return t1348648517839Entities != null && t1348648517839Entities.size() > 0
          ? t1348648517839Entities.size() :0;
    }
}
